/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package index;

import java.util.ArrayList;
import javax.xml.xpath.XPath;

/**
 *
 * @author mmenet
 */
public class Word {

    private String name;
    private int counter;
    private float frequency;
    private int weight;
    private ArrayList<FullWord> occurences;

    public Word(String name, String fullName, String element,
            String elementType,
            String document,
            int position) {
        this.name = name;
        occurences = new ArrayList<FullWord>();
        addOne(fullName, element, elementType, document, position);
    }

    public void addOne(String fullName,
            String element,
            String elementType,
            String document,
            int position) {
        occurences.add(new FullWord(fullName, element, elementType, document, position));
        counter++;
    }

    public void updateFrequency(int allWordsCounter) {
        frequency = (float) counter / (float) allWordsCounter;
    }

    public String getName() {
        return name;
    }

    public int getCounter() {
        return counter;
    }

    public float getFrequency() {
        return frequency;
    }

    public int getWeight() {
        return weight;
    }

    public ArrayList<FullWord> getOccurences() {
        return occurences;
    }

    public String toString() {
        return new StringBuffer("Name : ").append(name).append(", ")
                .append("Counter : ").append(counter).append(", ")
                .append("Frequency : ").append(frequency).append(", ")
                .append("Weight : ").append(weight)
                .toString();
    }
}
